<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
%>

<!--  修改学科组 -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
		<title>修改教研室</title>
	<link href="<%=path %>/css/index_css.css" rel="stylesheet" type="text/css" />
		<script language="javascript" src="<%=path %>/js/jquery.js"></script>
	<script type="text/javascript">
	var objectHIDDENID="";
	function checkForm()
	{
	  var name=document.getElementById("orgname").value;
	  if(name=="")
	  {
	    alert("名称不能为空！");
	    return false;
	  }
	  var sort=document.getElementById("sort");
	  if(!/^-?[\d]{0,9}$/.test(sort.value)){
	  	alert("序号格式不正确！");
	  	sort.focus();
	    return false;
	  }
	  //2010-10-12  添加设置教研室负责人
         var paramArr="";
        
         var userId =document.getElementsByName("UserId");
		 if(userId!=null && userId.length>0){
			for(var i=0;i<userId.length;i++){
				paramArr+=userId[i].value+",";
			}
			document.getElementById("UserIds").value=paramArr;
		 }

	  submitForm();
	
	}
	
	 function giveParamArr(){
	  		return document.getElementById(objectHIDDENID).value;
	  }
	
	function choseUser(){
	  objectHIDDENID="UserIds";
	  parent.objectHIDDENID=objectHIDDENID;
	  if('${applicationScope.currentYear}'==null || '${applicationScope.currentYear}'==""){
		alert("未设置当前年度，请通知管理员进行设置！");
		return;
	   	}
       var url="<%=path%>/toSelectTeacherorganizationAction.action?years=${applicationScope.currentYear}&role.roleId=jyzz&actionURL=&t="+new Date();	
		
	   parent.displayModuleDiv2(url);
    }
	
	function doChooseUser(returnStr){
	  var idStr="";
		if(returnStr==undefined){
			return;
		}
		if(returnStr!=null && returnStr!=""){
			var UserArr = returnStr.substring(0,returnStr.length-1).split(",");
			var UserNameStr="";
				for(var i=0;i<UserArr.length;i++){
					var user=UserArr[i];
					var sonArr=user.split("_");
					if((i+1)%5==0){
						UserNameStr+="&nbsp;&nbsp;"+sonArr[1]+"&nbsp;&nbsp;&nbsp;"+"<input name=\"UserId\" type=\"hidden\" value=\""+sonArr[0]+"\"/><br>";
					}else{
						UserNameStr+="&nbsp;&nbsp;"+sonArr[1]+"&nbsp;&nbsp;&nbsp;"+"<input name=\"UserId\" type=\"hidden\" value=\""+sonArr[0]+"\"/>";
					}
					idStr+=sonArr[0]+",";
				}
				document.getElementById("UserIds").value=idStr;
				if(UserNameStr!=""){									
					document.getElementById("pName").innerHTML=UserNameStr;					
				}	
		}
		else
		{
			document.getElementById("pName").innerHTML="点击此处设置教研室负责人";
		}
    }
    	//提交
	function submitForm() {
			var url = "<%=path %>/saveOrUpdateStaffRoomorganizationAction.action"
			$.post(url,
				$('#staffRoomForm').serialize(), 
				function(data){
					parent.refreshJsp();		
			})
	}
	</script>

  </head>
  
  <body bgcolor="#ECE9D8">
  <form id='staffRoomForm' action="<%=path %>/saveOrUpdateStaffRoomorganizationAction.action" method="post" name="staffRoomForm">
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="25" align="left" valign="bottom" bgcolor="#ECE9D8" class="f_8"><table width="100%"><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;注：<span class="f_11">*</span>为必填项</td><td align="right"></td></tr></table></td>
  </tr>
  <tr>
    <td height="12" align="center" valign="middle" bgcolor="#ECE9D8"><table width="95%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="1" bgcolor="#ABA899"></td>
      </tr>
      <tr>
        <td height="1" bgcolor="#FFFFFF"></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="25" align="center" valign="top" bgcolor="#ECE9D8"><table width="95%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="40" align="right" class="f_6">编号：</td>
        <td align="left" valign="middle">${organization.organizationId }</td>
      </tr>
      <tr>
        <td width="25%" height="30" align="right" class="f_6"><span class="f_11">* </span>教研室名称：</td>
        <td width="75%" align="left">
        <input type="text" name="organization.name" id="orgname" value="${organization.name }" maxlength="25"/>
        <input type="hidden" name="organization.orgType" value="1" />
        </td>
      </tr>
      
	  <tr>
	     <td height="30" align="right" bgcolor="#ECE9D8" class="f_6" nowrap="nowrap">教研室负责人：</td>
	     <td align="left">
	     <input type="hidden" name="years" value="${applicationScope.currentYear }"/>
	     <input type="hidden" name="role.roleId" value="jyzz"/>
	     <div style="border:1px;border-style:dotted; background-color: #FFFFFF;width: 150px" onclick="choseUser();" class="border_3"onmouseover="this.style.backgroundColor='#e4f5ff'" onmouseout="this.style.backgroundColor=''" style="cursor:pointer;" id="pName">
	     <c:choose>
	     <c:when test="${! empty requestScope.UserList}">
	     <c:forEach items="${requestScope.UserList}" var="User" varStatus="i" begin="0" step="1">        
	     <c:set value="${user.userId},${totalArr}" var="totalArr"></c:set>              
		 <c:if test="${i.count%5==0}">
			 &nbsp;&nbsp;${user.name }&nbsp;&nbsp;<input name="UserId" type="hidden" value="${user.userId }"/><br>
		 </c:if>
		 <c:if test="${i.count%5!=0}">
			 &nbsp;&nbsp;${user.name }&nbsp;&nbsp;<input name="UserId" type="hidden" value="${user.userId }"/>
		 </c:if>  
		 </c:forEach>
	     </c:when>
	     <c:otherwise>
	      点击此处设置教研室负责人
	     </c:otherwise>
	     </c:choose>
	     </div>
	     <input type="hidden"  value="${totalArr}" id="UserIds" name="UserIds" />
	     </td>
	  </tr>
  
      <tr>
        <td height="30" align="right" class="f_6">序号：</td>
        <td align="left">
        <input type="text" name="organization.sort" value="${organization.sort }" id="sort"/>
       
	        <input type="hidden" value="${organization.organizationId }" name="organization.organizationId" />
	        <input type="hidden" value="${organization.registerTime }" name="organization.registerTime" />
	        <input type="hidden" value="${organization.parent }" name="organization.parent" />
        </td>
      </tr>
      <tr>
        <td height="30" align="right" valign="top" class="f_6">包含课程：</td>
        <td align="left" valign="top">
        <table width="400" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td align="left" valign="top" class="tb_10 border_2">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <c:choose>
                  <c:when test="${! empty courseList}">
                    <c:set value="1" var="i" />
                    <c:forEach items="${courseList}" var="course">
                     <tr>
                      <td height="25" align="left">
                        <c:set value="" var="ischeck" />
                        <!-- 判断复选框是否选中 -->
                        <c:if test="${! empty organization.courses}">
                          <c:forEach items="${organization.courses}" var="cour">
                            <c:if test="${cour.courseId eq course.courseId}">
                              <c:set value="checked" var="ischeck" />
                            </c:if>
                          </c:forEach>
                        </c:if>
                        
                      	
                      <!-- 修改bug12 修改人：闷男 -->
                      
                      		<input type="checkbox" name="courseId" value="${course.courseId }" ${ischeck } }/>${course.name }
                      		<!-- 修改此处，删除部分代码，不需要判断单位的问题，直接将全部功能开放出来  2012-3-13 -->
                        <!-- 闷男修改结束 -->
                      </td>	
                        </tr>
                      <c:set value="${i+1}" var="i" />
                    </c:forEach>
                  </c:when>
                  <c:otherwise><td><font color="#CCCCCC">无课程信息</font></td></c:otherwise>
                </c:choose>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="25" align="center" valign="middle" bgcolor="#ECE9D8">
    <table width="95%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="1" bgcolor="#ABA899"></td>
      </tr>
      <tr>
        <td height="1"><br></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="25" align="center" valign="middle" bgcolor="#ECE9D8"><input type="button" name="button" onclick="checkForm();" value="提 交" /></td>
  </tr>
</table>
</form>
  </body>
</html>
